<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head th:include="common_include :: commonHead('邮件账号添加')"/>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <form class="form-horizontal m" id="form-account-add">
                <div class="form-group">
                    <label class="col-sm-3 control-label">邮件服务器：</label>
                    <div class="col-sm-8">
                        <input type="hidden" name="serverKey" id="serverKey"/>
                        <input type="text" name="serverName" id="serverName" class="form-control" placeholder="邮件服务器" readonly="true" required="true" onclick="selectEmailServerList()">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">账户名称：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" name="accountName" id="accountName" required="true">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label ">邮箱地址：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" name="username" id="username" required="true"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label ">邮箱密码：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="password" name="password" id="password" required="true"/>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<div th:include="common_include :: commonFoot"/>
<script th:src="@{/libs/service/js/service-email.js}"></script>
<script type="text/javascript">
    var prefix = ctx + "service/email/account"

    $("#form-account-add").validate({
        rules: {
            username: {
                required: true,
                remote: {
                    url: prefix + "/checkRecordUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        serverKey: function () {
                            return $.trim($("#serverKey").val());
                        },
                        username: function () {
                            return $.trim($("#username").val());
                        }
                    },
                    dataFilter: function (data, type) {
                        return data == "0";
                    }
                }
            },
        },
        messages: {
            "username": {
                remote: "该邮件用户名称已经存在"
            }
        },
        submitHandler: function (form) {
            $.operate.save(prefix + "/add", $('#form-account-add').serialize());
        }
    });

    function submitClick() {
        if($('#form-account-add').valid()){
            $('#form-account-add').submit()
        }
    }
</script>
</body>
</html>
